rows affected by the operation, i.e. the total number of items (nothing to say)*/}function Quant_items ($table, $session) {/*Returns the total number of items (that is, two identical items are counted as two objects--#)*/$quant = Total amount of 0;//items$query = SELECT * from $table WHERE session= ' $session ';$result = mysql_query ($query);while ($row = Mysql_fetch_object ($result)) {/*Take each item out individually*/$quant + = $row->quantity; The amount of the item is added to the total amo
Practical php shopping cart program. Practical php Tutorial shopping cart program previously used a good feeling, but it also feels very good, so I will introduce it to friends who need it for reference .? Php calls the instance require _ Practical php
the same time.
3. function implementation process1. add product functionsThe principle of adding a product is: first create a shopping cart, and then use the product ID ($ _ GET [id]) transmitted by the "buy" link on the product display page as the basis, add item (item ID) to the shopping cart and do not allow repea
PHP Shopping cart is in the e-commerce site will be used, like a supermarket shopping cart, choose a good product, first put in their own shopping cart and so on to the counter settlement, this section of the PHP
follows:
Header ("content-type:text/html;charset= utf-8");Session_Start (); Initializing Session VariablesSession_register ("Goodsid"); Define session variables for storing commodity IDsSession_register ("Goodsnum"); Define session variables to store the number of items purchasedif ($_session["Goodsid"]== "" $_session["Goodsnum"]== "") {//Determine if the SESSION variable is empty$_session["Goodsid"]=$_get["id"]. " @"; If the session variable is em
$master _products_list = Array ();
Load Item Data function
function Loadproducts () {
Global $master _products_list;
$filename = ' products.txt ';
$fp = @fopen ($filename, "R")
Or Die ("Open $filename file failed");
@flock ($FP, 1)
Or Die ("Lock $filename file failed");
Read File contents
while ($line = fgets ($fp, 1024)) {
List ($id, $name, $desc, $price) = Explode (' | ', $line); Read each row of data, data to | GE Kai
$id = Trim ($id); Remove the special symbols from the tail
$master _pr
Php shopping cart code. Here we provide you with a simple php shopping cart code. from adding shopping products and purchasing products, this function is indispensable in mall development and we do not need a database, here we provide you with a simple php
addition of the product operation function, which $promote_name is a promotion of the parameters, in particular, using the strategy model to choose which promotional strategy, I am prepared to discuss the next article specifically. As long as you know it is to add the basic information of this product, deposit into the shopping cart database.
Next is the second action:
Copy CodeThe code is as follows:
/**
PHP Shopping Cart Example here also provides a PHP shopping cart instance code, which is suitable for the development of the mall or shopping system reference development examples, tell you if you add merchandise to the shopping a
PHP Single example mode to realize shopping cart function-php Instance tutorial complete this small function must write the need to develop good habits PHP shopping cart development requirements function is as follows 1: Shopping
operation, i.e. the total number of items (nothing to say)*/}function Quant_items ($table, $session) {/*Returns the total number of items (that is, two identical items are counted as two objects--#)*/$quant = Total amount of 0;//items$query = SELECT * from $table WHERE session= ' $session ';$result = mysql_query ($query);while ($row = Mysql_fetch_object ($result)) {/*Take each item out individually*/$quant + = $row->quantity; The amount of the item is added to the total amount.}return $quant; R
Php shopping cart implementation code (12 ). About shopping cart, this is a lot of use in e-commerce, the user selects their own items need to be saved, and finally go to the cashier, this is like our actual life of the supermarket, the shopping
Mainly is the shopping cart part code explanation, and to the session operation PHP Tutorial code demonstration.
//add_item.php:Add an item to the shopping cart.//Session_Start ();if (session_is_registered (' cart ')) {Session
--#)
*/
$quant = Total amount of 0;//items
$query = SELECT * from $table WHERE session= ' $session ';
$result = mysql_query ($query);
while ($row = Mysql_fetch_object ($result)) {
/*
Take each item out individually
*/
$quant + = $row->quantity; The amount of the item is added to the total amount.
}
return $quant; Return Total
}
}
http://www.bkjia.com/PHPjc/320144.html www.bkjia.com true http://www.bkjia.com/PHPjc/320144.
Php shopping cart instance (15 ). The php shopping cart instance provides a php shopping cart instance code, which is a development instance suitable for the development of the mall or shoppin
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.